package org.zjt.ds;

/**
 * @author juntao.zhang
 * @version V1.0
 * @Description: 多线程同时加载类，形成死锁
 * @Package org.zjt.ds
 * @date 2018/4/24 21:23
 */
public class LoadClassDeathLock {

    /**
     *  多线程加载类，形成一个死锁。
     * @param args
     */
    public static void main(String[] args) {
        new Thread(()-> new A("")).start();
        new Thread(()-> new B("")).start();
    }
}

class A{
    static B b_class;
    static {
        b_class = new B("B class");
    }
    private final String name;

    A(String name) {
        this.name = name;
    }
}

class B{
    static A a_class;
    static {
        a_class = new A("A class");
    }
    private final String name;

    B(String name) {
        this.name = name;
    }
}
